<?php

namespace Admin\Controller;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/10 0010
 * Time: 13:59
 */

class ManagerController extends CommonController
{
    //公司级
    public function company_list() {
        //查询具有危险源为公司级的风险点id和名称
        $sql= " select id,  name from   xc_danger where id=(select danger_id from xc_object where  object_level_id=1 and status=1)";

        $Data = M('danger'); //实例化Data数据模型
        $list= $Data->query($sql);
        if (!empty($list)) {
            foreach ($list as $k=>$v) {
                //根据风险点ID查询，风险等级为1的
                //  $list[$k]['type_name'] = M('ObjectType')->where(['id' => $v['type_id']])->getField('name');
                $map['danger_id'] =  $v['id'];
                $map['object_level_id'] = '1';
                $map['status'] = '1';
                $res2 =   M('object')->where($map)->select();
                $list[$k]['voo'] = $res2   ;
            }
        }
        $this->assign('list', $list);

        /*
        $map['status'] = '1';
        $map['type_id'] = '6';
        //'status = 1'
        $list = $this->lists('danger',$map, 'id asc');
        if (!empty($list)) {
            foreach ($list as $k=>$v) {
              //  $list[$k]['type_name'] = M('ObjectType')->where(['id' => $v['type_id']])->getField('name');
            }
        }
        $this->assign('list', $list);
*/

        $this->display('company_list');

    }
    public function company_do()
    {
         if (IS_GET) {
            $object_id = $_GET['object_id'];
            //  $post['create_time'] = time();
             echo $object_id;

             $this->display('company_do');
       }else
        {

           echo '开发中';
       }
    }
//专业级
    public function part_list() {

      //  $sql="select t.id, t.numbers, t.dqtimes,t.datetimes,t.state,t.taocan,t.token,t.wechat_id,t.xdtimes,t.yucun ,case   when   CURDATE()>=date(dqtimes) then '已过期'  else '未过期' end 'youxiao' from imicms_number t where t.state=1 and t.wechat_id='";

      //  $sql='select  *  from xc_part where status = 1  ';
      //  $Data = M('part'); //实例化Data数据模型
      //  $list= $Data->query($sql);
        //部门表
        $list = $this->lists('part','status = 1', ' id asc');
        if (!empty($list)) {
            foreach ($list as $k => $v) {
                //车间表
                $res2 = M('workshop')->where(['part_id' => $v['id']])->select();
                $list[$k]['voo'] = $res2;
                }

                $this->assign('list', $list);// 赋值数据集

            }
        $this->display('part_list');

            /*
        $sql='select  *  from xc_workshop where status = 1';
       // and part_id =';
        //$sql= $sql.$vo['id'];
        $Data = M('workshop'); //实例化Data数据模型
        $res2= $Data->query($sql);
        // $res2 = $this->lists('workshop', $where, ' id asc');
        if ($res2) {
            foreach ($res2 as $k1 => $sub) {
                // $res2[$k1]['name'] = M('workshop')->where(['part_id' => $v['id']])->getField('name');
                echo  count($res2);
            }
            */
          //  var_dump($res2);

        //    $this->assign('res2', $res2);

            /*
                    $list = $this->lists('part','status = 1', ' id asc');
                    if (!empty($list)) {
                        foreach ($list as $k=>$v) {
                            //  $list[$k]['type_name'] = M('ObjectType')->where(['id' => $v['type_id']])->getField('name');
                            //$list[$k]['danger_name'] =  M('danger')->where(['id' => $v['danger_id']])->getField('name');
                        }
                    }
                   $this->assign('list', $list);
            */
        }

  //车间级
    public function workshop_list() {
        echo '开发中';
    }
}

